package com.dada.domain.admin;

import com.dada.dada.domain.tables.pojos.User;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by jianweilin on 16/9/5.
 */
public class UserInfo {
    private String username;

    public UserInfo toEntiry(@NotNull User user){
        UserInfo userInfo = new UserInfo();
        BeanUtils.copyProperties(user,userInfo);
        return userInfo;
    }

    public List<UserInfo> toInfoList(@NotNull List<User> users){
        return users.stream().map((User user) -> toEntiry(user)).collect(Collectors.toList());
    }
}
